<template>
    <div>
        <h1>注册页面</h1>
        <table>
            <tr>
                <td>账号</td>
                <td>
                   <input type="text" v-model="state.lname" />
                </td>
            </tr>
            <tr>
                <td>密码</td>
                <td>
                    <input type="password" v-model="state.lpwd" />
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" value="登录" @click="denlu"/>
                </td>
              
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import { reactive, toRefs, onMounted} from 'vue' 
import { useRoute, useRouter } from 'vue-router'
import axios from 'axios'

const route = useRoute()
const router = useRouter()

const date = reactive({
  state:{
      lname:'',
      lpwd:''
  }

})

const {state} = toRefs(date)


const denlu = () => {
    if(state.value.lname==""){
        alert("账号不能为空")
        return
    }
    if(state.value.lpwd==""){
        alert("密码不能为空")
        return
    }
    console.log(state.value);
    axios({
        url:'https://localhost:7246/api/Login/ShowLogin',
        method:'get',
        params:state.value

    }).then((res)=>{
        console.log(res)
        if(res.data.data>0){
            alert("成功")
        }
       if(res.data.data==-2){
            alert("账号错误")
            return
       }
       if(res.data.data==-3){
            alert("密码错误")
            return
       }
    })
    .catch((err)=>{
        console.log(err)
    })
}


</script>

<style scoped>

</style>